home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / system / bsvc-1.000 / bsvc-1 / bsvc-1.0.4 / src / Sim68000 / devices / DeviceRegistry.cxx next >
Encoding:
C/C++ Source or Header  |  1995-07-26  |  2.2 KB  |  71 lines

  1. /////////////////////////////////////////////////////////////////////////////// //
  2. // $Id: DeviceRegistry.cxx,v 1.1 1994/02/18 20:11:53 bmott Exp $
  3. /////////////////////////////////////////////////////////////////////////////// //
  4. // DeviceRegistry.cxx
  5. //
  6. //   This class keeps up with a list of all of the availible devices and
  7. // allocates them.  It's derived from the BasicDeviceRegistry
  8. //
  9. // Sim68000 "Motorola 68000 Simulator"
  10. // Copyright (c) 1993
  11. // By: Bradford W. Mott
  12. // October 30,1993
  13. //
  14. ///////////////////////////////////////////////////////////////////////////////
  15. // $Log: DeviceRegistry.cxx,v $
  16. // Revision 1.1  1994/02/18  20:11:53  bmott
  17. // Initial revision
  18. //
  19. ///////////////////////////////////////////////////////////////////////////////
  20.  
  21. #include <iostream.h>
  22. #include "DeviceRegistry.hxx"
  23. #include "RAM.hxx"
  24. #include "M68681.hxx"
  25.  
  26. ///////////////////////////////////////////////////////////////////////////////
  27. // Array of device information (name, description, tcl script)
  28. ///////////////////////////////////////////////////////////////////////////////
  29. const DeviceInformation DeviceRegistry::device_info[] = {
  30.   {"RAM",
  31.    "Random Access Memory",          
  32.    #include "RAM.scr"
  33.   },
  34.   {"M68681",
  35.    "Motorola 68681 Dual UART",
  36.    #include "M68681.scr"
  37.   }
  38. };
  39.  
  40. ///////////////////////////////////////////////////////////////////////////////
  41. // The Constructor
  42. ///////////////////////////////////////////////////////////////////////////////
  43. DeviceRegistry::DeviceRegistry()
  44.     : BasicDeviceRegistry(device_info,
  45.           sizeof(device_info)/sizeof(DeviceInformation))
  46. {}
  47.  
  48. ///////////////////////////////////////////////////////////////////////////////
  49. // Create a device with the given name (return 1=OK,0=ERROR)
  50. ///////////////////////////////////////////////////////////////////////////////
  51. int DeviceRegistry::Create(String& name, String& args, BasicCPU *cpu,
  52.                            BasicDevice* &device) 
  53. {
  54.   if (name=="RAM")
  55.     device=new RAM(args, cpu);
  56.   else if (name=="M68681")
  57.     device=new M68681(args, cpu);
  58.   else
  59.     return(0);
  60.  
  61.   // If the device's error message is not empty then return error
  62.   if(device->GetErrorMessage()!="")
  63.   {
  64.     delete device;
  65.     return(0);
  66.   }
  67.  
  68.   return(1);
  69. }
  70.  
  71.